import java.util.Arrays;
import java.util.Scanner;

public class EGYPIZZA {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);

		// Enter number of testcases
		int testcases;
		testcases = in.nextInt();

		int i = 0;
		int[] pizzaShareArr = new int[testcases];
		while (testcases != 0) {
			String pizzaShare = in.next();
			pizzaShareArr[i] = pizzaShare.charAt(0) - '0';
			int denominator = pizzaShare.charAt(2) - '0';
			if (denominator == 2) {
				pizzaShareArr[i] *= 2;
			}
			i++;
			testcases--;
		}

		Arrays.sort(pizzaShareArr);
		System.out.println(calculateNumberPizza(pizzaShareArr));
	}

	private static int calculateNumberPizza(int[] pizzaShareArr) {
		int pizzaCount = 1;
		int end = pizzaShareArr.length - 1;
		int start = 0;
		while (end > start) {
			int sum = pizzaShareArr[end];
			while (((sum + pizzaShareArr[start]) <= 4) && (end > start)) {
				sum += pizzaShareArr[start];
				start++;
			}
			pizzaCount++;
			end--;
		}
		if ((end == start) && (pizzaShareArr[end] + pizzaShareArr[start] >= 4)) {
			pizzaCount++;
		}
		return pizzaCount;
	}
}
